import { http } from "@/utils/http";
import { Result, arrayResult } from "../types";
import { exportExcel } from '@/utils/exportExcel'

export type data = {
  fromStorePlaceID?: number,
  toStorePlaceID?: number,
  agvId?: number,
  agvID?: number,
  num?: number,
  batch?: string,
  JobOnlyId?: string,
  jobId?: number
};

type search = {
  jobonlyid?: string,
  batch?: string,
  agvid?: number,
  startLocId?: number,
  endLocId?: number,
  userid?: number,
  status?: number,
  dateRange?: number,
  begin?: string,
  end?: string,
}


// 任务列表
export const jobList = (params?: search) => {
  return http.request<Result>("get", "/api/job/List", { params });
};

// 新增作业任务
export const CreateJob = (data: data) => {
  return http.request<Result>("post", "/api/job/CreateJob", { params: data });
};

// 新增入库任务
export const Warehousing = (data: data) => {
  return http.request<Result>("post", "/api/job/Warehousing", { params: data });
};

// 新增出库任务
export const Outbound = (data: data) => {
  return http.request<Result>("post", "/api/job/Outbound", { params: data });
};

// 删除任务
export const jobDelete = (data: data) => {
  return http.request<Result>("post", "/api/job/Delete", { params: data });
};

// 优先执行
export const Priority = (data: any) => {
  return http.request<Result>("post", "/api/job/Priority", { params: data });
};

// 更换车辆
export const UpdateJobAgv = (data: any) => {
  return http.request<Result>("post", "/api/job/UpdateJobAgv", { params: data });
};

// 清空出库货位
export const EmptyOut = () => {
  return http.request<Result>("post", "/api/racklocations/EmptyOut", {});
};

// 导出告警列表
export function excelJob(data, fileName) {
  exportExcel('/api/job/Excel', data, fileName);
}

// 车辆移动
export const CreateMove = (data: data) => {
  return http.request<Result>("post", "/api/job/CreateMove", { params: data });
};

// 车辆充电
export const CreateChargePileTask = (data: data) => {
  return http.request<Result>("post", "/api/job/CreateCharge", { params: data });
};

// 车辆停靠
export const CreateParking = (data: data) => {
  return http.request<Result>("post", "/api/job/CreateParking", { params: data });
};

// 废弃任务
export const jobDiscard = (data: data) => {
  return http.request<Result>("post", "/api/job/Discard", { params: data });
};

// 移动任务(一楼)
export const MoveAgv = (data: data) => {
  return http.request<Result>("post", "/api/job/MoveAgv", { params: data });
};

// 初始化任务
export const Initialize = (data: data) => {
  return http.request<Result>("post", "/api/job/Initialize", { params: data });
};

export const GetAllStatusStorePlaceList = () => {
  return http.request<Result>("get", "/api/locations/GetAllStatusStorePlaceList", {  });
};
